module;


export module Code_8_2_1;

constexpr bool
doIsPrime(unsigned p, unsigned d) // p: number to check, d: currentdivisor
{
    return d != 2 ? (p % d != 0) && doIsPrime(p, d - 1) // check this and smallerdivisors
        : (p % 2 != 0); // end recursion if divisor is 2
}
constexpr bool isPrime1(unsigned p)
{
    return p < 4 ? !(p < 2) // handle special cases
        : doIsPrime(p, p / 2); // start recursion with divisor fromp/2
}

constexpr bool isPrime(unsigned int p)
{
    for (unsigned int d = 2; d <= p / 2; ++d)
    {
        if (p % d == 0)
        {
            return false; // found divisor without remainder
        }
    }
     return p > 1; // no divisor without remainder found
}
export
namespace Code_8_2_1 {

    void run()
    {
        constexpr bool b1 = isPrime(9);
    }
}